import { axios as request  } from '@/utils/request'
import qs from 'qs'

export function getList({params}) {
  params['checkTransportNoList'] = []
  // 如果params.settlementIdList里的某一项的length 小于10，就赋值给params.checkTransportNoList并从params.settlementIdList里删除
  params.settlementIdList.forEach((item, index) => {
    if (item.length < 10) {
      params['checkTransportNoList'].push(item)
    }
  })
  params.settlementIdList = params.settlementIdList.filter(item => item.length >= 10);
  delete params.checkTransportNo
  // 如果有分页的话，需要删除pageNo和pageSize
  delete params.pageNo
  delete params.pageSize
  return request({
    url: 'api/finance/check?' + qs.stringify(params, {indices: false, encode: false}),
    method: 'get'
  })
}

export function get(params) {
  return request({
    url: `api/finance/check?${params}`,
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: 'api/finance/check/settlement',
    method: 'post',
    data
  })
}

export function reconciliation(data) {
  return request({
    url: 'api/finance/check/reconciliation',
    method: 'post',
    data
  })
}